package com.frame.demo.app;

import android.app.Application;

import com.frame.demo.injector.component.ApplicationComponent;
import com.frame.demo.injector.component.DaggerApplicationComponent;
import com.frame.demo.injector.moudle.ApplicationModule;

import javax.inject.Inject;

/**
 * App启动初始化各个模块
 * @author liuxia
 * @version 1.0
 * @date 2015/12/22
 */
public class MyApplication extends Application {

    private ApplicationComponent mApplicationComponent;
    @Inject
    static MyApplication mMyApplicationInstance;

    public static MyApplication getInstance() {
        return mMyApplicationInstance;
    }

    @Override
    public void onCreate() {
        super.onCreate();
        setupGraph();
    }

    private void setupGraph() {
        mApplicationComponent = DaggerApplicationComponent.builder()
                .applicationModule(new ApplicationModule(this))
                .build();
        mApplicationComponent.inject(this);
    }

    public ApplicationComponent component() {
        return mApplicationComponent;
    }
}
